var scene;
var camera;
var renderer;
function init(xscene, xrenderer, xcamera) {
  scene = xscene;
  camera = xcamera;
  renderer = xrenderer;
//   console.log("scene", scene, camera, renderer);
}

function addListener(visibilitychange) {
  window.addEventListener("resize", resizeLisenter);
  window.addEventListener("visibilitychange", visibilitychange);
}

function resizeLisenter() {
//   console.log("scene", scene);
//   console.log("resize", window.innerWidth, window.innerHeight);
  renderer.setSize(window.innerWidth, window.innerHeight); //设置渲染器尺寸
  camera.aspect = window.innerWidth / window.innerHeight;
  camera.updateProjectionMatrix();
  renderer.render(scene, camera);
}

function removeEvent(visibilitychange) {
  window.removeEventListener("resize", resizeLisenter);
  window.removeEventListener("visibilitychange", visibilitychange);
}

export { init, addListener, removeEvent };
